home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
rjs.lha
/
RJS
/
String
/
src
/
trim.C
< prev
next >
Wrap
C/C++ Source or Header
|
1991-06-14
|
639b
|
42 lines
#include "String.h"
#include "ctype.h"
RJS_String &RJS_String::trim(Side t)
{
char *p,*q;
int len,i;
q=p=sd.data;
if (isspace(*q) && (t & Left)) {
len=0; i=0;
while (i<length() && isspace(*q)) q++,i++; // skip white space
while (i<length()) { // copy non-white space
*p++ = *q++;
i++;
len++;
}
} else len=length();
if (t & Right) while(len && isspace(sd.data[len-1])) len--;
if (len!=length()) trunc(len);
return *this;
}
RJS_String trim(const char *s,Side t)
{
RJS_String temp(s);
return temp.trim(t);
}
RJS_String trim(const RJS_String &s,Side t)
{
RJS_String temp(s);
return temp.trim(t);
}